DrawPaletteMappedStrip16
DrawPaletteMappedStrip16 Xpos, Ypos, Address, Length, Mask
 
Parameters:

    Xpos = The output X coordinate of this strip of pixels
    Ypos = The output Y coordinate of this strip of pixels
    Address = The Address of the series of bytes to get the colour indexes from
    Length = Number of pixels / byte in this strip
    Mask = Mask to apply to the colour index before reading the palette.
Returns: NONE
 

     DrawPaletteMappedStrip16 reads a sequential runs of 16bit word values from memory and renders them out to the current surface using a user defined colour palette. So it treats each 16bit byte as the index to the palette array, where the palette contains up to an array of 32bit (ARGB) colours. 16Bit Palettes can contain up to 2^16=65536 unique colours.

     Using this command we can simulate classic effects like raster bars, mirrors, shadows and glez vectors to name a few.



FACTS:


      * Palette Mapping is used in a classic computer/game console display systems since it's very efficient way of storing images.

      * Using the CreateFxImageEx command it's possible use 16bit FX images to create your palette mapped screen and sprites with.





Example:


      This example is using the DrawPaletteMappedStrip16 to render a 4096 colour palette. The screen colour indexes are set up so that each pixel on screen is the distance from the screen center. The palette created each frame from 16 banks of 256 colours. Each block of 256 colours is shaded via sinus and offset in the palette table, creating the illusion of pixel motion when only the colours are changing.


 
Example Source: Download This Example
  // Include the palette Mapping library
  #Include "paletteMapping"
  
  
  // Define
  Dim Palette(256)
  
  SetPalette(Palette())
  
  
  // ------------------------------------
  // CReate a palette mapped Screen in memory
  // ------------------------------------
  
  Width=800
  Height=600
  
  // Alloc a bank that we'll use as the screen
  ScreenBank=NewBank(Width*Height)
  
  // Fill the bank with colour values..
  For ylp =0 To Height-1
     
     // Compute the address of this strip
     RowAddress=GetBankPtr(ScreenBank)+Width*ylp
     
     // Fill this row of bytes with
     For Xlp=0 To Width-1
        
        Pos=WrapValue(Xlp+ylp,0,Width)
        
        // Compute the colour index using sinus
        ColourIndex = Sin( (180.0/Width) *Pos)* 255
        
        // copy it to the screen buffer
        PokeByte RowAddress+Xlp, ColourINdex
     Next
     
  Next
  
  
; Limit the program to 100 frames per second or less
  SetFPS 100
  
  
  Do
     
     // ------------------------------------
     // Pick the Palette main colour
     // ------------------------------------
     
     If ScrollX=0
        
        // pick a random colour that we'll use to seed the palette
        ThisColour =RndRGB()
     EndIf
     
     
     
     
     // ------------------------------------
     // Fill the palette with all 256 shades
     // ------------------------------------
     
     // fill the palette array with all the shades of thsi colour
     For lp =0 To 255
        Pos=(ScrollX+lp) And 255
        Palette(pos)=RgbAlphaMult(ThisColour,RGB(lp,lp,lp))
     Next
     
     // offset the palette creation it's a little more interesting
     ScrollX=(ScrollX-2And 255
     
     
     
     
     // -----------------------------------------------------------
     // Draw this 8bit palette mapped data to the actual screen
     // -----------------------------------------------------------
     
     LockBuffer
   ; read a point from the output surface to make sure
   ; it's seeded for raw direct output rendering
     ThisRgb=Point(0,0)
     
   ; Run down the scan lines and draw them to the screen
     For ylp =0 To Height-1
        
        // Compute the address of this strip
        RowAddress=GetBankPtr(ScreenBank)+Width*ylp
        
        DrawPaletteMappedStrip8(0,ylp,RowAddress,Width,255)
     Next
     UnLockBuffer
     
     
     Sync
  Loop EscKey()=true
  
  
  
  
  
 
Related Info: ARGB | DrawPaletteMappedStrip8 | IndexToRGB | RGBtoINDEX | SetPalette :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com